<?php
include('../Lib/php/conex.php');
$link= conectaSQL("influenza","inf123456","influenza");
include('../Lib/php/fechas.php');

import_request_variables("gP");

$diaActual = floor(date("d"));
$mesActual = floor(date("n"));
if ($sector > 1) $filtroSector = " and id_sector = $sector ";
$nTipoPaciente = "nTipoPaciente in (1,2)";
//$mes = date("m");
$dias = array();

// CONSTRUYE QUERY
//---------------------------------------------------------------------------------------------------------
$sql = "SELECT ";
$contador = 0;

//------------------------------------------------------------------------------------------------------------
$subtitulo_dias = "FECHA DE INICIO DE SINTOMAS";
//$subtitulo_dias = "DIAS DE ". traducemes(date("M"));
if($tipoPaciente == " nTipoPaciente in (1)") $incremento = 2; else $incremento = 2;

$sql ="select fSintoma_Inicial,count(*),SUM(CASE WHEN nLabResultado = 1 THEN 1 ELSE 0 END)
from dat_registro where nTipoPaciente in (1,2) AND nStatus = 1 $filtroSector
group by fSintoma_Inicial";

$resultado = mssql_query($sql,$link);

$i=0;
while ($filas = mssql_fetch_row($resultado)){
	$data[$i][0] = convertdate5($filas[0]);	
	$data[$i][1] = $filas[1];	
	$data[$i][2] = $filas[2];			
	$i++;
}			

//print_r($data);
//return;
include('../Lib/php/phplot-5/phplot.php');
$plot = new PHPlot(650, 250);
$plot->SetIsInline(TRUE)
$which_btype = "full";				//Plot Border  // plotleft,plotright,both,full,none, 
$wind_graph_min = 1;
$wind_graph_max = 40;
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
$plot->SetPlotType('area'); 
$plot->SetMarginsPixels(40,40,20,20); 
$plot->SetPlotAreaWorld(0.5,$wind_graph_min,36.5,$wind_graph_max); 

$plot->DrawGraph();
/*//	$plot->SetXLabelType();
	$plot->SetXLabel($subtitulo_dias);
	$plot->SetYLabel("Casos");
	$plot->SetTTFPath(getcwd());
	$plot->SetDefaultTTFont("arial.ttf");	
//	$plot->SetTitle("CASOS DE ETI/IRAG E INFLUENZA  A(H1N1)");
    $plot->SetLegend(array("ETI/IRAG","A(H1N1)"));	
	$plot->SetXDataLabelAngle(90);	
	$plot->SetDataColors(array('orange','red', 'green', 'blue','SlateBlue',
'ivory','YellowGreen','beige','brown','gold','gray','yellow',
'lavender','magenta','azure1','aquamarine1','orchid','peru','pink','plum','purple','navy'));
	
 
// Coloca la escala del eje Y y el tipo de incremento
//$plot->SetPlotAreaWorld(NULL, 0,NULL,NULL);
$plot->SetYTickIncrement($incremento);
$plot->SetXTickIncrement(1);
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->SetPrecisionY(0);
$plot->SetXLabelAngle(90);		
$plot->SetFont('title','',8);	
//$plot->SetXTickIncrement(1);
 
 //Other settings
$plot->SetBackgroundColor("#FfFFFF");		
$plot->SetTextColor("blue");
$plot->SetGridColor("black");
$plot->SetLightGridColor(array(175,175,175));
$plot->SetTickColor("black");
$plot->SetTitleColor("navy"); // Can be array or name
$plot->SetPlotBorderType($which_btype);		


$plot->DrawGraph();
*/
?>